;getprofileint ("Settings","Frameleft", -1)) -1! = (b = AfxGetApp ()->getprofileint ("Settings","Framebottom", -1)) -1! = (R = AfxGetApp ()->getprofileint ("Settings","Frameright", -1)) {windowplacement WP; //Restore the window ' s statusWp.showcmd =s; //Restore the window ' s width and heightWp.rcNormalPosition.bottom =b; Wp.rcNormalPosition.right=R; //The following correction is needed when the taskbar is//At the left or top and it's not "A
file: winuser. h; library file: user32.lib.========================================================== ======================================== Getwindowplacement Function: This function returns the display status of the specified window and the restored, maximized, and minimized window position.Function prototype: bool getwindowplacement (hwnd, windowplacement★Lpwndpl );Parameters:Hwnd: window-day handle.Lpwndpl: pointer to the
: winuser. h; library file: user32.lib.========================================================== ======================================== Getwindowplacement Function: This function returns the display status of the specified window and the restored, maximized, and minimized window position.Function prototype: bool getwindowplacement (hwnd, windowplacement★Lpwndpl );Parameters:Hwnd: window-day handle.Lpwndpl: pointer to the
Centerwindow () is used as follows:
Void centerwindow (cwnd * palternateowner = NULL );
The palternateowner parameter points to the pointer of the window to be centered.
Then, use the getsystemmetrics (INT nindex) function to obtain the current system settings, such as screen resolution.
Nindexs = sm_cxscreen; Unit: pixel.
Nindexs = sm_cyscreen: the height of the screen returned by the function; Unit: pixel.
The function bool getwindowplacement (windowplacem
Centerwindow () is used as follows:Void centerwindow (cwnd * palternateowner = NULL );The palternateowner parameter points to the pointer of the window to be centered.Then, use the getsystemmetrics (INT nindex) function to obtain the current system settings, such as screen resolution.Nindexs = sm_cxscreen; Unit: pixel.Nindexs = sm_cyscreen: the height of the screen returned by the function; Unit: pixel.The function bool getwindowplacement (windowplacement
() function: (Inside the WINDOWS API Response message Wm_in99vdialog) SetTimer (1, 1, NULL); (2). Add the message handler function OnTimer that handles Wm_timer, add code: if (nidevent = = 1)
{
Deletetimer (1);
ShowWindow (Sw_hide);
The disadvantage of this method is obvious, the use of the timer, so that the stability of the program seems to be a discount; the window is to be displayed first, then the effect is the window flashed away.
2. Changing the display status of a dialog box changes its
it.
Method:
1. Set the timer in the oninitdialog () function: (the Windows API responds to the Message wm_in99vdialog)
Settimer (1, 1, null );
2. Add the message processing function ontimer for processing wm_timer and add the Code:
If (nidevent = 1)
{
Deletetimer (1 );
Showwindow (sw_hide );
}
The disadvantage of this method is obvious. Using a timer makes the program's stability seem to offer a discount. The window needs to be displayed first, so the effect is that the window disappears.
2. Ch
document at startup?
[Problem]How can I prevent my program from creating a new document at startup?[Answer]Before the processshellcommand function in the initinstance of the program, add: cmdinfo. m_nshellcommand = ccommandlineinfo: filenothing.
47. How can I shield the right-click menu on the title bar?
[Solution]Right-click the system menu and remove the ws_sysmenu attribute.[Program Implementation]Int cmainframe: oncreate (maid){........Long style = getwindowlong (m_hwnd, gwl_style );Style
cdialogexdlg: oninitdialog ()
{
Cdialog: oninitdialog ();
// Do something
Windowplacement WP;
WP. Length = sizeof (windowplacement );
WP. Flags = wpf_restoretomaximized;
WP. showcmd = sw_hide;
Setwindowplacement (% 26; amp; WP );
Return true;
}
When you need to display it (usually the mouse message that responds to the hot key or tray icon ):
Windowplacement WP;
dialog box display status
You can hide a dialog box by changing its display attribute during initialization. The method is to call the setwindowplacement function:
Bool cdialogexdlg: oninitdialog ()
{
Cdialog: oninitdialog ();
// Do something
Windowplacement WP;
WP. Length = sizeof (windowplacement );
WP. Flags = wpf_restoretomaximized;
WP. showcmd = sw_hide;
Setwindowplacement ( WP );
Return true;
}
When
Full Screen Display is essential for some applications. For example, when using VC ++ to edit resources such as the Project source file or the editing dialog box, select "viewfull screen" to enter the full screen display status, press the "ESC" key to exit full screen display.
In VC ++ 6.0, Appwizard is used to generate the application framework of the Single-Document Interface by default. Next, we will first discuss how to click the menu item "viewfull screen" to achieve full screen display, an
give it a time to show it, we are hiding it.Method:1. Set the timer in the oninitdialog () function: (wm_initdialog in the Windows API) settimer (1, 1, null );2. Add the message processing function ontimer for processing wm_timer and add the Code:If (nidevent = 1){Deletetimer (1 );Showwindow (sw_hide );}The disadvantage of this method is obvious. Using a timer makes the program's stability seem to offer a discount; the window must first displayAs shown, the window disappears.2. Change the displ
, we can hide it.
Method:
1. Set the timer in the oninitdialog () function: (wm_initdialog in the Windows API)Settimer (1, 1, null );2. Add the message processing function ontimer for processing wm_timer and add the Code:If (nidevent = 1){Deletetimer (1 );Showwindow (sw_hide );}The disadvantage of this method is obvious. Using a timer makes the program's stability seem to offer a discount. The window needs to be displayed first, so the effect is that the window disappears.2. Change the display
(Note: This code has a certain risk, such as you can not control your computer, please log off or restart)
First, build a single document application framework
Second, to hide the main window, will be oncreate deleted.
and modify the m_pMainWnd in the app class to point to ShowWindow (Sw_hide)
Three, now in the mainframe implementation file add the following content: Point Mp,cursornew; ///////////////////////////////////////CMainFrame construction/destruction UINT fmouse (LPVOID param)
MFC no blinking hidden window, mfc flashing window
You need to hide the window program today, but if you are in OnInitDialog (), write:
ShowWindow (SW_HIDE );
It is invalid because it is an initialization window function. That is to say, this function is called when the window is not displayed. Therefore, there is no window handle, so it cannot be hidden.
I found a solution on the internet today to solve this problem:
ModifyStyleEx (WS_EX_APPWINDOW, WS_EX_TOOLWINDOW); // remove. SetWindowPo
1. Define the window size after a CRect is saved and started.
M_rect
2. Write the following code in the OninitDialog event:
GetWindowRect ( m_rect );
WINDOWPLACEMENT wp;
Wp. length = sizeof (WINDOWPLACEMENT );
Wp. flags = WPF_RESTORETOMAXIMIZED;
Wp. showCmd = SW_HIDE; SetWindowPlacement ( wp );
// Set a timer to hide the timer and then return to the original state, or reply in the real window,
SetTimer (6,
1. In the dialog boxProgram, Add the following before the return of oninitdialog ()CodeThe process can only appear in the task manager.// Hide the dialog boxModifystyleex (ws_ex_appwindow, ws_ex_toolwindow );Windowplacement WP; // hideWP. Length = sizeof (windowplacement );WP. Flags = wpf_restoretomaximized;WP. showcmd = sw_hide;Setwindowplacement ( WP );
2. In the single-document program, change the param
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.